<!--评价等次明细表-->
<template>
  <el-dialog title="租户微服务管理" :close-on-click-modal="false" :visible.sync="visible" width="30%">
    <el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()"
      label-width="200px">
      <el-form-item label="系统微服务权限" prop="adminFlag">
        <el-select :disabled="true" v-model="dataForm.adminFlag" placeholder="请选择状态" class="xiaLa">
          <el-option v-for="item in  [{label: '是',value: '1'}, {label: '否',value: '0'}]" :key="item.value"
            :label="item.label" :value="item.value">
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="测评微服务权限" prop="cepingFlag">
        <el-select v-model="dataForm.cepingFlag" placeholder="请选择状态" style="margin-left:10px" class="xiaLa">
          <el-option v-for="item in  [{label: '是',value: '1'}, {label: '否',value: '0'}]" :key="item.value"
            :label="item.label" :value="item.value">
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="奖金微服务权限" prop="jiangjinFlag">
        <el-select v-model="dataForm.jiangjinFlag" placeholder="请选择状态" style="margin-left:10px" class="xiaLa">
          <el-option v-for="item in  [{label: '是', value: '1'}, { label: '否',value: '0' }]" :key="item.value"
            :label="item.label" :value="item.value">
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="合同任务微服务权限" prop="hetongFlag">
        <el-select v-model="dataForm.hetongFlag" placeholder="请选择状态" style="margin-left:10px" class="xiaLa">
          <el-option v-for="item in  [{label: '是', value: '1'}, { label: '否',value: '0' }]" :key="item.value"
            :label="item.label" :value="item.value">
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="日常考核微服务权限" prop="richangFlag">
        <el-select v-model="dataForm.richangFlag" placeholder="请选择状态" style="margin-left:10px" class="xiaLa">
          <el-option v-for="item in  [{label: '是', value: '1'}, { label: '否',value: '0' }]" :key="item.value"
            :label="item.label" :value="item.value">
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="统计分析微服务权限" prop="tongjiFlag">
        <el-select v-model="dataForm.tongjiFlag" placeholder="请选择状态" style="margin-left:10px" class="xiaLa">
          <el-option v-for="item in  [{label: '是', value: '1'}, { label: '否',value: '0' }]" :key="item.value"
            :label="item.label" :value="item.value">
          </el-option>
        </el-select>
      </el-form-item>
    </el-form>
    <span slot="footer" class="dialog-footer">
      
      <el-button type="primary" @click="dataFormSubmit()" v-if="canSubmit">确定</el-button>
      <el-button @click="visible = false">取消</el-button>
    </span>
  </el-dialog>
</template>

<script>
  import {
    addObj,
    putObj,
    getObj
  } from '@/api/admin/tenant'

  export default {
    data() {
      return {
        visible: false,
        canSubmit: false,
        dataForm: {
          id: 0,
          jiangjinFlag: '',
          cepingFlag: '',
          adminFlag: ''

        },
        dataRule: {

        }
      }
    },
    methods: {
      init(id) {
        this.dataForm.id = id || 0;
        this.visible = true;
        this.canSubmit = true;
        this.$nextTick(() => {
          this.$refs['dataForm'].resetFields()
          if (this.dataForm.id) {
            getObj(this.dataForm.id).then(response => {

              this.dataForm = response.data.data
             //console.log(this.dataForm)
            })
          }
        })
      },
      // 表单提交
      dataFormSubmit() {
        this.$refs['dataForm'].validate((valid) => {
          if (valid) {
            this.canSubmit = false;
            if (this.dataForm.id) {
              putObj(this.dataForm).then(data => {
                this.$notify.success('修改成功')
                this.visible = false
                this.$emit('refreshDataList')
              }).catch(() => {
                this.canSubmit = true;
              });
            } else {
              addObj(this.dataForm).then(data => {
                this.$notify.success('添加成功')
                this.visible = false
                this.$emit('refreshDataList')
              }).catch(() => {
                this.canSubmit = true;
              });
            }
          }
        })
      }
    }
  }

</script>
